// 检测是否在 Tauri 环境中
export const isTauri = (): boolean => {
    return (
        typeof window !== 'undefined' && (window as any).__TAURI__ !== undefined
    );
};

// 获取 API 基础 URL
export const getApiBaseUrl = (): string => {
    if (isTauri()) {
        return import.meta.env.VITE_API_BASE_URL || 'http://localhost:8080/api';
    }

    return import.meta.env.VITE_API_BASE_URL || '/api';
};

// 获取环境变量
export const getEnv = (key: string, defaultValue: string = ''): string => {
    return import.meta.env[key] || defaultValue;
};
